package geez.widget;

import com.google.gwt.user.client.ui.Widget;
import static geez.widget.Geez.*;

public class ZebraPanel extends GFlowPanel<ZebraPanel> {

    private String oddStyle;
    private String evenStyle;
    private boolean isEven = true;

    public ZebraPanel() {
        super();
    }

    public ZebraPanel(String oddStyle, String evenStyle) {
        this.oddStyle = oddStyle;
        this.evenStyle = evenStyle;
    }

    public ZebraPanel appendRow(Widget widget) {
        return append(flowPanel()
            .css(nextCssStyle())
            .append(widget));
    }

    private String nextCssStyle() {
        isEven = !isEven;
        return isEven ? evenStyle : oddStyle;
    }
}
